﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RangeValidator2.MaximumValue = DateTime.Now.ToShortDateString();
        }

        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value == "admin")
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (ful.HasFile == true)
            {
                string fileName = ful.FileName;
                if (fileName.EndsWith(".jpg") || fileName.EndsWith(".jpeg") || fileName.EndsWith(".png") || fileName.EndsWith(".gif"))
                {
                    string url = Server.MapPath(@"~\img\" + fileName);
                    ful.SaveAs(url);
                    Image1.ImageUrl = @"~\img\" + fileName;
                }
                else
                {
                    this.ClientScript.RegisterClientScriptBlock(GetType(), "提示", "<script>alert('文件格式不正确！')</script>");
                    //Literal1.Text = "<script>alert('文件格式不正确！')</script>";
                    //Literal1.Text = "文件格式不正确！";
                    return;
                }
            }
            else
            {
                Literal1.Text = "<script>alert('上传的文件不能为空！')</script>";
                //Literal1.Text = "上传的文件不能为空！！";
                return;
            }
            if (Page.IsValid)
            {
                Literal1.Text = "注册成功！ <a href='/WebForm7.aspx'>点击跳转到登录页面</a>";
            }
        }
    }
}